import {Root} from 'tui-lib/ui/primitives'
import {CommandLineInterface} from 'tui-lib/util/interfaces'

import AppElement from './basic-app.js'

const clInterface = new CommandLineInterface()

clInterface.getScreenSize().then(size => {
  const root = new Root(clInterface)
  root.w = size.width
  root.h = size.height

  const appElement = new AppElement()
  root.addChild(appElement)
  root.select(appElement)

  appElement.on('quitRequested', () => {
    process.exit(0)
  })

  setInterval(() => root.render(), 100)
}).catch(error => {
  console.error(error)
  process.exit(1)
})
